// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;

import MainControl from "./mainControl"

@ccclass
export default class GameStart extends cc.Component {

    @property(cc.Node)
    bird: cc.Node = null;
    @property(cc.Animation)
    animation: cc.Animation = null;

    @property(MainControl)
    mainControl: MainControl = null;

    // 常驻节点
    @property(cc.Node)
    persistentNode: cc.Node = null;


    onLoad(){
        // 将当前节点设为常驻节点
        cc.game.addPersistRootNode(this.persistentNode);
    }
    start() {
        this.mainControl = cc.find("persistentNode").getComponent("mainControl");

        // init logic
        this.animation = this.bird.getComponent(cc.Animation);
        this.animation.play("birdLoop");
    }

    beginGame() {
        this.mainControl.beginGame();
    }

    // update (dt) {}
}
